      /*
 * ShapeChildren.java
 *
 * Created on September 21, 2006, 9:10 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 *
 * To understand this class, see http://platform.netbeans.org/tutorials/nbm-nodesapi3.html
 */
package org.netbeans.shapesimple.palette;


import java.util.ArrayList;
import org.openide.nodes.Index;
import org.openide.util.Exceptions;


/**
 *
 * @author Geertjan Wielenga
 */
public class ShapeChildren extends Index.ArrayChildren
{
    
    private Category category;
    private String[][] items = new String[][]
    {
        {
            "0" , "Shapes" , "Triangle 0" , "org/netbeans/shapesimple/palette/image1.png"
        } ,
        {
            "1" , "Shapes" , "Triangle 1" , "org/netbeans/shapesimple/palette/image2.png"
        } ,
        {
            "2" , "Pictures" , "Triangle 2" , "org/netbeans/shapesimple/palette/image3.png"
        }
    };
    

    public ShapeChildren( Category Category )
    {
        this.category = Category;
    }
    

    @Override
    protected java.util.List initCollection()
    {
        ArrayList childrenNodes = new ArrayList( items.length );
        try
        {
            for ( int i = 0; i < items.length; i++ )
            {
                if ( category.getName().equals( items[i][1] ) )
                {
                    Shape2 item = new Shape2(items[i][2],new Integer( items[i][0] ),items[i][1],items[i][3]);
//                    item.setNumber( new Integer( items[i][0] ) );
//                    item.setCategory( items[i][1] );
//                    item.setTitle( items[i][2] );
//                    item.setImage( items[i][3] );
                    childrenNodes.add( new ShapeNode( item ) );
                }
            }
        }
        catch ( Exception e )
        {
            Exceptions.printStackTrace( e );
        }
        return childrenNodes;
    }
    
}